package com.dong.design.builder;

import java.util.ArrayList;
import java.util.List;

/**
 * 套餐
 *
 * @author jianyang206881
 * @date 2018/6/8
 */
public class Meal {
    private List<Item> itemList = new ArrayList<>();

    public void addItem(Item item) {
        itemList.add(item);
    }

    public float getCost() {
        float cost = 0.0f;
        for (Item item : itemList) {
            cost += item.price();
        }
        return cost;
    }

    public void showItem() {
        itemList.forEach(item -> {
            System.out.println("Item : " + item.name() + ", Packing : " + item.packing().pack() + ", Price : " + item.price());
        });
    }
}
